﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class Download : IAccessible<T_Download, Download>, ILogicEntity<T_Download, Download>
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Remark { get; set; }
        public DateTime CreateDate { get; set; }
        public DownloadType Type { get; set; }
        public int OrgId { get; set; }
        public string Path { get; set; }
        public OrganizationType OrgType { get; set; }

        protected override void Covariant(T_Download model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.Path = model.Path;
                this.Title = model.Title;
                this.Remark = model.Remark;
                this.CreateDate = model.CreateDate;
                this.Type = (DownloadType)model.Type;
                this.OrgId = model.OrgId;
                this.OrgType = (OrganizationType)model.OrgType;
            }
        }

        protected override T_Download Inverter(Download model)
        {
            if (model != null)
            {
                return new T_Download()
                {
                    CreateDate = model.CreateDate,
                    Id = model.Id,
                    Path = model.Path,
                    Remark = model.Remark,
                    Title = model.Title,
                    Type = (int)model.Type,
                    OrgId = model.OrgId,
                    OrgType=(int)model.OrgType
                };
            }
            return null;
        }

        public Download Set(T_Download dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
